#include "thread.h"

int checkDir(sharInfo_t*sharInfo,MYSQL*mysql,char* word,int* goalID){
    char order[1024];
    bzero(order,sizeof(order));
    
    int parID=sharInfo->parentID;
    if(parID==-1){
        parID=sharInfo->rootID;
    }
    sprintf(order,"select ID from df_mes where parID=%d and fileName='%s' and tomb =0;",parID,word);
    int qret=mysql_query(mysql,order);
    if(qret != 0){
        fprintf(stderr,"mysql_query:%s\n", mysql_error(mysql));
        return -1;
    }
    MYSQL_RES *result=mysql_store_result(mysql);
    int rows=mysql_num_rows(result);
    if(!rows){
        return -1;
    }
    MYSQL_ROW row=mysql_fetch_row(result);

    if(goalID){

        *goalID=atoi(row[0]);
    }
    mysql_free_result(result);
    return 0;

}
